﻿
using System.Data.SqlClient;

namespace NSQLObjectsTests.DBModel
{
    static class CustomTypeMap
    {
        internal static void FromSql(this SqlDataReader reader, int index, out short sVal) {
            if (reader.IsDBNull(index))
                sVal = 0;
            else
                sVal = reader.GetInt16(index);
        }

        internal static void ToSql(this SqlParameter parameter, short sVal) {
            parameter.DbType = System.Data.DbType.Int16;
            parameter.Value = sVal;
        }

        internal static void FromSql(this SqlDataReader reader, int index, out float fVal) {
            if (reader.IsDBNull(index))
                fVal = 0;
            else
                fVal = reader.GetFloat(index);
        }

        internal static void ToSQL(this SqlParameter parameter, float fVal) {
            parameter.DbType = System.Data.DbType.Single;
            parameter.Value = fVal;
        }
    }
}
